file(GLOB_RECURSE _PS_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")

if (NOT (ENABLE_CPU AND (ENABLE_D OR ENABLE_GPU)))
    list(REMOVE_ITEM _PS_SRC_FILES "optimizer_info_builder.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "optimizer_info.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "scheduler.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "util.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "embedding_table_shard_metadata.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/http_message_handler.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/http_server.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/comm_util.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/tcp_client.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/tcp_message_handler.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/tcp_server.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/cluster_config.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/node.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/node_manager.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "ps_cache/ps_cache_manager.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/worker_node.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/server_node.cc")
    list(REMOVE_ITEM _PS_SRC_FILES "core/abstract_node.cc")
endif ()

if (NOT ENABLE_D)
    list(REMOVE_ITEM _PS_SRC_FILES "ps_cache/ascend/ascend_ps_cache.cc")
endif()

if (NOT ENABLE_GPU)
    list(REMOVE_ITEM _PS_SRC_FILES "ps_cache/gpu/gpu_ps_cache.cc")
endif()

list(REMOVE_ITEM _PS_SRC_FILES "ps_cache/ps_data/ps_data_prefetch.cc")
list(REMOVE_ITEM _PS_SRC_FILES "ps_cache/ps_data/ps_data_channel.cc")
add_subdirectory(ps_cache)

set_property(SOURCE ${_PS_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_PS)
add_library(_mindspore_ps_obj OBJECT ${_PS_SRC_FILES})
